# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=libddoc
pkgver=0.7.2
pkgrel=2
pkgdesc="D implementation of the DDoc macro system"
url="https://github.com/dlang-community/libddoc"
arch="x86_64 aarch64" # ldc
license="BSL-1.0"
makedepends="libdparse-dev ldc ldc-runtime"
subpackages="$pkgname-dev"
source="https://github.com/dlang-community/libddoc/archive/v$pkgver/libddoc-$pkgver.tar.gz"

build() {
	# Makefile can't do that for us :/
	ldc2 $(pkg-config --cflags dparse) $(pkg-config --libs dparse | sed -r 's|-l([A-Za-z]+)|-L=-l\1|g') src/ddoc/* -shared -Os -soname=libddoc.so.${pkgver%%.*} -of libddoc.so
}

check() {
	ldc2 $(pkg-config --cflags dparse) $(pkg-config --libs dparse | sed -r 's|-l([A-Za-z]+)|-L=-l\1|g') src/ddoc/* -unittest -main -g -Os -of libddoc-tests
	./libddoc-tests
}

package() {
	# Makefile doesn't do that for us :/
	install -Dm755 libddoc.so "$pkgdir"/usr/lib/libddoc.so.$pkgver
	ln -s libddoc.so.$pkgver "$pkgdir"/usr/lib/libddoc.so.${pkgver%%.*}
	ln -s libddoc.so.${pkgver%%.*} "$pkgdir"/usr/lib/libddoc.so

	mkdir -p "$pkgdir"/usr/include/d/
	cp -r src "$pkgdir"/usr/include/d/ddoc
}

sha512sums="b01a7cc0f81639f8817d3c5cbdb5a4d0e9c9b55f817535f8b3356f73086a2b08b6f1115bcc5abbdf0bb948bb1ed5136b91df0e53da8c2228f568ec3bc0e9eee2  libddoc-0.7.2.tar.gz"
